package behavioral.templateMethod.custom;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 西瓜汁
 */
public class WatermelonJuice extends Beverage{

    @Override
    protected void addGoods() {
        System.out.println("添加西瓜");
    }

    @Override
    public void addCondiments() {
        System.out.println("添加 冰块");
    }

    @Override
    protected boolean needCondiments() {
        String userInput = getUserInput();
        return userInput.toLowerCase().startsWith("y");
    }

    private String getUserInput() {
        String result = "";
        System.out.println("需要加点冰吗？");
        BufferedReader in  = new BufferedReader(new InputStreamReader(System.in));
        try {
            result = in.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (result == null) {
            return "no";
        }
        return result;
    }
}
